home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / doom / suckmods.zip / SUCKMODS.ZIP / suck05 / src / ghostdaemon.qc < prev    next >
Text File  |  1997-05-09  |  1KB  |  37 lines

  1. // Code to get rid of ghost players which take up spaces on the server.
  2. // Brought to you courtesy of Suck.  Sends comments and questions to
  3. // suck@linux.mit.edu
  4.  
  5. void() ghost_daemon_think =
  6. {
  7.     local entity p;
  8.  
  9.     p=find(world, classname, "player");
  10.  
  11.     while (p!=world)
  12.     {
  13.         // Unconnected players _do_ run PlayerPreThink, but
  14.         // Quake doesn't clear the player structure after
  15.         // a player leaves, so we have to see if a player
  16.         // hasn't thought in a while.  If so, clear his
  17.         // thought_count for new players who will join
  18.         // and use the same player structure
  19.         if ((p.last_thought+1)<time)
  20.             p.thought_count=0;
  21.         if (p.netname == "unconnected")
  22.         {
  23.             // When you join a game, your name is initially
  24.             // set to unconnected for a few cycles.  Therefore,
  25.             // we cannot blindly kick players named unconnected.
  26.             // Instead, we have to kick players named unconnected
  27.             // who have been thinking for a while, because
  28.             // unconnected players do keep thinking.
  29.             if (p.thought_count>100)
  30.                 localcmd("kick unconnected\n");
  31.         }
  32.         p=find(p, classname, "player");
  33.  
  34.     }
  35.     self.nextthink=time+0.3;
  36. };
  37.